<?php

namespace SinoPHP\BbdBoss\Model;

use Upfor\UpforPHP\Model;

class ServerIpLog extends Model {

    /**
     * 获取指定ip的日志列表
     *
     * @param string $fields
     * @param null   $id
     * @param null   $limit
     * @param null   $offset
     * @return array
     */
    public function getLogList($fields = '', $id = null, $limit = null, $offset = null) {

        $sql = "SELECT 
                  {$fields} 
                FROM 
                  `server_ip_log` 
                LEFT JOIN `admin_user` ON `server_ip_log`.`admin_user_id`=`admin_user`.`admin_user_id`
                WHERE `server_ip_log`.`ip_id` = {$id} ORDER BY `server_ip_log`.`create_time` DESC ";

        if($limit) {
            $sql .= " LiMIT {$offset},{$limit}";
        }

        $data = $this->db->query($sql);
        return $data;
    }

}
